#include "Comm.hpp"

int main()
{
    Fifo fifo(Path);
    int rfd = open(Path, O_RDONLY);
    if(rfd < 0)
    {
        cerr << "open fail errno" << errno << "strerror : " << strerror(errno)<<endl;
        return 1;
    }
    
    cout<<"read of open success"<<endl;

    char buffer[128];
    while(true)
    {
        ssize_t n = read(rfd,buffer,sizeof(buffer));
        if(n<0)
        {
            cerr << "read fial errno" << errno <<" , strerrno is : "<< strerror<<endl;
            break;
        }
        else if( n == 0)
        {
            cout<<"client is quitting now, me too!"<<endl;
            break;
        }
        else
        {
            buffer[n]=0;
            cout<< "client say: "<< buffer << endl;
        }
    }   

    close(rfd);
    return 0;
}